/*
 ============================================================================
 Name		: TerraEngine.h
 Author	  : Jan Sanchez
 Version	 : 1.0
 Copyright   : For testing purposes only!
 Description : CTerraEngine declaration
 ============================================================================
 */

#ifndef TERRAENGINE_H
#define TERRAENGINE_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include <senxmlservicedescription.h>
#include "Service.h"
#include "ServiceCallback.h"

// @param KServiceEndpoint holds the web address for accesing Terra's web service.
_LIT8(KServiceEndpoint, "http://terraservice.net/TerraService2.asmx");
// @param KState Constant for sending state value (in our case it will be null).
_LIT(KState, "");

_LIT(KConnectionError, "Connection error. Please try again later.");

// CLASS DECLARATION

/**
 *  CTerraEngine
 * 
 */
class CTerraEngine : public CBase
	{
public:
	// Constructors and destructor

	/**
	 * Destructor.
	 */
	~CTerraEngine();

	/**
	 * Two-phased constructor.
	 */
	static CTerraEngine* NewL();

	/**
	 * Two-phased constructor.
	 */
	static CTerraEngine* NewLC();
	
public:
	
	/**
	 * Function for getting the location (city, country) after inputting the latitude and longitude.
	 */
	void GetLocationL();

	/**
	 * Function for getting UTM data (zone, x and y coordinates) after inputting the latitude and longitude.
	 */
	void GetUTML();
	
	/**
	 * Function for getting the latitude and longitude after inputting the location (city, country).
	 */
	void GetCoordinatesL();

	/**
	 * Shows a multiline query dialog to ask the user for inputing a latitude and a longitud
	 * @param aTitle1 Title of the 1st parameter
	 * @param aTitle2 Title of the 2nd parameter
	 * @param aLat TInt for getting the latitude value
	 * @param aLong TInt for getting the longitude value
	 */
	TInt ShowQueryDialogL(const TDesC& aTitle1, const TDesC& aTitle2, TInt& aLat, TInt& aLong);
	
	/**
	 * Shows a multiline query dialog to ask the user for inputing a city and a country
	 * @param aTitle1 Title of the 1st parameter
	 * @param aTitle2 Title of the 2nd parameter
	 * @param aCity TDes for getting the city value
	 * @param aCountry TDes for getting the country value
	 */	
	TInt ShowQueryDialogL(const TDesC& aTitle1, const TDesC& aTitle2, TDes& aCity, TDes& aCountry);
	
	/**
	 * Show an information dialog with the results
	 * @param TDesC that is displayed
	 */
	TInt ShowInfoDialogL(const TDesC& anInfo);


private:

	/**
	 * Constructor for performing 1st stage construction
	 */
	CTerraEngine();

	/**
	 * EPOC default constructor for performing 2nd stage construction
	 */
	void ConstructL();
	
	/**
	 * Initializes objects needed for connecting to the web service
	 * and waits for ServiceCallback::SetStatus
	 */
	void ConnectL();
	
	/**
	 * iObserver member for setting the status if iService gets initialized correctly
	 */
	CTerraCallback* iObserver;
	/**
	 * iService main member for accesing the web service
	 */
	CTerraServiceService* iService;

public:
	
	
	
	};

#endif // TERRAENGINE_H
